<?php
/**
 * WAVESELF FRAMEWORK
 * 
 * Waveself framework is an open source project released under New BSD license.
 * Waveself Engine Team did this in order to help you as ourselves with different
 * but still easy to use and learn approach. 
 * 
 * Please read license before you do any changes or to say, before using current software
 * read our licence which can be found under waveself framework root folder.
 * 
 * If you did not recieve copy of licence, contact us immediately and we will send you copy.
 * 
 * @category   Waveself
 * @package    System Configuration
 * @author     Nevio Vesic <nevio.vesic@gmail.com>
 * @copyright  Waveself Framework NPO 2009-2010
 * @license    https://code.google.com/p/waveself-framework/source/browse/trunk/LICENSE   New-BSD
 * @version    0.1a
 */

/**
 * Used for loading waveself components. Consider this as global autoloader.
 * If in any cases you use another autoloader as well, DO NOT register this one
 * as well.
 * 
 * @category    Waveself
 * @package     Engine
 * @subpackage  Loader
 * @author      Nevio Vesic <nevio.vesic@gmail.com>
 * @copyright   Waveself 2009-2010. 
 * @version     $id: 
 */
class Waveself_Engine_Loader
{
	/**
	 * Autoload method
	 *
	 * @param   String      $class
	 * @throws  Exception   If file can't be found!
	 */
	public static function load($class) 
	{
		$class = str_ireplace('_', '/', $class) . PHP_EXT;	
		if(! @fopen($class, 'r', true)) {
			throw new Exception("Cannot load '{$class}'. Check for file existance!");
		}
		require_once $class;
	}
}

/** Register Autoloader */
spl_autoload_register(array('Waveself_Engine_Loader', 'load'));